import 'package:enterprise_v6_app/app/components/special_operation/custom_approval_node_page.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_gas_count_down_page.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_select_function.dart';
import 'package:enterprise_v6_app/app/components/special_operation/custom_select_page.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/modules/application/special_operation/special_list/job_ticket/common/common_process/common_job_closed/common_job_closed_controller.dart';

///作业通用-作业关闭
class CommonJobClosedPage extends StatelessWidget {
  CommonJobClosedPage({super.key, this.isEnabled = false}){
    Get.lazyPut(CommonJobClosedController.new);
  }

  //节点是否可编辑
  final bool isEnabled;

  @override
  Widget build(BuildContext context) {
    final controller = Get.find<CommonJobClosedController>();
    return GetBuilder(
        init: controller,
        builder: (_) {
          return Container(
            margin: EdgeInsets.only(bottom: 60.w),
            color: const Color(0xFFF5F5F6),
            child: Column(
              children: [
                // Visibility(
                //   visible: controller.gasMilliseconds != 0,
                //   child: CustomGasCountDownPage(milliseconds: controller.gasMilliseconds),
                // ),
                // Visibility(
                //     visible: controller.gasMilliseconds != 0 && controller.jobMilliseconds != 0,
                //     child: AppGaps.vGap10),
                Visibility(
                  visible: controller.jobMilliseconds != 0,
                  child: CustomGasCountDownPage(promptText: '作业计划', milliseconds: controller.jobMilliseconds),
                ),
                Container(
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(8.w),
                  ),
                  margin: EdgeInsets.only(top: 12.w, left: 14.w, right: 14.w),
                  padding: EdgeInsets.symmetric(horizontal: 12.w),
                  child: CustomSelectPage(
                      title: '作业结束时间',
                      isEnabled: isEnabled,
                      selectText: controller.workAllPageController.executeEntity.endDate ?? '',
                      onCallBack: () {
                        CustomSelectFunction.selectDateTime(onCallBack: (String value) {
                          controller.workAllPageController.executeEntity.endDate = value;
                          controller.update();
                        });
                      }),
                ),
                Expanded(
                    child: ListView(
                  children: [
                    Container(
                      padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 12.w),
                      child: CustomApprovalNodePage(
                        isEnabled: isEnabled,
                        workCheck: controller.workAllPageController.executeEntity.workCheckList!,
                        onCallBack: () {
                          controller.update();
                        },
                      ),
                    )
                  ],
                ))
              ],
            ),
          );
        });
  }
}
